package aware;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class UserServiceImplAware implements ApplicationContextAware, BeanNameAware {
    private ApplicationContext context;
    private String name;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.context = applicationContext;
        System.out.println("让我知道容器对象，因为我实现了ApplicationContextAware接口--");
    }

    @Override
    public void setBeanName(String name) {
        this.name = name;
    }

    public void m() {

        System.out.println(context.hashCode());
        System.out.println(this.name);
    }


}
